package com.niiwoo.civet.account.dao.mapper;

import com.niiwoo.civet.account.dao.entity.AccountCompany;
import org.apache.ibatis.annotations.Param;

public interface AccountCompanyMapperExt extends AccountCompanyMapper{
	AccountCompany selectByUserId(@Param("userId") String userId);

	/**
	 * 根据用户ID、所属机构ID、帐户类型查询存管审核通过的机构
	 * @param userId
	 * @param orgId
	 * @param accountType
     * @return
     */
	AccountCompany selectAuditPassedAccountCompany(@Param("userId") String userId,@Param("orgId") String orgId,@Param("accountType") Byte accountType);

	Integer updateAuditStatusByOrgId(@Param("orgId") String orgId,@Param("auditStatus")Byte auditStatus);

	/**
	 * 根据营业执照编码查询企业帐户信息
	 * @param businessLicense
	 * @return
     */
	AccountCompany selectByBusinessLicense(@Param("businessLicense") String businessLicense);
	AccountCompany selectByAccountNo(@Param("accountNo")String accountNo);
	AccountCompany selectByOrgIdAndCompanyOrgId(@Param("orgId") String orgId, @Param("companyOrgId") String companyOrgId);

	/**
	 * 查询企业借款人在机构下的存管帐户
	 * @param orgId
	 * @param companyOrgId
	 * @param accountType
     * @return
     */
	AccountCompany selectByOrgIdAndCompanyOrgIdWithAccounType(@Param("orgId") String orgId, @Param("companyOrgId") String companyOrgId,@Param("accountType") Byte accountType);

	AccountCompany selectByOrgIdAndUserIdWithAccountType(@Param("userId") String userId,@Param("orgId") String orgId, @Param("accountType") Byte accountType);

	/**
	 * 根据机构ID与企业借款人ID查询存管机构信息
	 * @param orgId
	 * @param userId
     * @return
     */
	AccountCompany selectByOrgIdAndUserId(@Param("orgId") String orgId,@Param("userId") String userId);

	/**
	 * 根据存管帐户编号更新审核状态
	 * @param accountNo
	 * @param auditStatus
     * @return
     */
	Integer updateAuditStatusByAccountNo(@Param("accountNo") String accountNo,@Param("auditStatus")Byte auditStatus);

	/**
	 * 根据平台帐户编号更新
	 * @param record
	 * @return
     */
	int updateByAccountNo(AccountCompany record);

	/**
	 * 重置账户银行卡号与银行编码
	 * @param accountId
	 * @return
     */
	int resetBankCardNoAndBankCode(@Param("accountId") Long accountId);
}